﻿@using QqhrCitizen.Models;
@using QqhrCitizen.Models.ViewModel;
@{
    ViewBag.Title = "产品修改";
    Layout = "~/Views/Shared/_Layout.cshtml";

    User user = ViewBag.User as User;
    vProduct product = ViewBag.Product as vProduct;
}

<script src="~/Scripts/jQuery-File-Upload/js/vendor/jquery.ui.widget.js"></script>
<script src="~/Scripts/jQuery-File-Upload/js/jquery.iframe-transport.js"></script>
<script src="~/Scripts/jQuery-File-Upload/js/jquery.fileupload.js"></script>
<script src="~/Scripts/jQuery-File-Upload/js/jquery.fileupload-process.js"></script>
<script src="~/Scripts/jQuery-File-Upload/js/jquery.fileupload-validate.js"></script>

<div id="d_menu" class="d-menu menu-use">
    <div id="d_menu_c" class="d-menu-c">
        <!-- region start: menu -->
        <div id="d_headmenu" class="d-headmenu">
            <div class="body">
                <a id="headmenu_useraccount" class="item_selected" href="/User/Show/@user.ID">个人信息</a>
                <a id="headmenu_history" class="item" href="/User/HistoryCourse/@user.ID">学习档案</a>
            </div>
        </div>
        <!-- region end: menu -->
    </div>
</div>
<div id="d_bottom" class="d-bottom" style="visibility: hidden; position: fixed;"><div class="d-bottom-c"><div id="d_scrolltop" class="d-scrolltop" style="right: -70px;"><span class="t" onclick="$('html,body').animate({scrollTop: '0px'}, 800);">顶部</span></div></div></div>
<div class="d-row" style="padding:0 0 40px 0">
    <div class="d-row-c">
        <div class="d-col-2-8">
            <div class="contentarea">
                <h2>修改作品</h2>
                @using (Html.BeginForm("EditProductInfo", "User", FormMethod.Post, new { enctype = "multipart/form-data" }))
                {
                    @Html.AntiForgeryToken()
                    <input type="hidden" id="txtProductID" name="ProductID" value="@product.ID" />
                    <div class="PuidHide">

                    </div>
                    <div>
                        <h4>标题</h4>
                        <input type="text" name="Title" class="int-hs" style="width:200px;"  value="@product.Title"/>
                    </div>
                    <div style="margin-top:20px;">
                        <h4>简介</h4>
                        <textarea name="Description" class="int-hs" cols="100" rows="10">
                            @product.Description
                        </textarea>
                    </div>
                    <div>
                        <h4>视屏</h4>
                        <div>
                            <input type="file" id="fileupload" name="files[]" />
                            <div class="videoWarning"></div>
                        </div>

                    </div>
                    <div>
                        <h4>缩略图(大小不能超过3M)</h4>
                        <input type="file" id="imgFileupload" name="files[]" />
                        <div class="imgWarning"></div>
                    </div>
                    <div style="margin-top:20px;">
                        <input type="submit" class="btn btn-orange btn-big" value="保存" style="width:100px;">
                    </div>
                }
            </div>
        </div>
        <div class="d-col-2-4">
            <div class="contentarea">
                <!-- region start: 个人设置 -->
                <div id="d_settings" class="d-settings">
                    <div class="head">
                        &nbsp;
                    </div><div class="body">
                        <div class="item">
                            <a href="/User/PwdEdit/@user.ID">修改密码</a>
                        </div>
                        <div class="item">
                            <a href="/User/Edit/@user.ID">修改个人信息</a>
                        </div>
                        <div class="item">
                            <a href="/User/Product">作品信息</a>
                        </div>
                        <!--<div class="item">
                            <a href="/usercenter/verify">实名认证</a>
                        </div>-->
                    </div>
                </div>
                <!-- region end: 个人设置 -->
                <input type="hidden" id="redirect" name="redirect">
            </div>
        </div>
        <div class="clear"></div>
    </div>
</div>
<script>
    var ProductID = $("#txtProductID").val();
    $('#fileupload').fileupload({
        url: "/User/VideoUpload?ProductID=" + ProductID,
        dataType: 'json',
        autoUpload: true,
        maxFileSize: 307200000, // 300 MB
        done: function (e, data) {//设置文件上传完毕事件的回调函数
            if (data.result.filePath == "") {
                alert("上传失败！");
                return false;
            }
            else {
                var str = "<input type='hidden' value='" + data.result.PUId + "' name='InfoID' />";
                $(".videoWarning").html("上传成功");
                $(".PuidHide").html(str);
              
            }
        }
    });

    $('#imgFileupload').fileupload({
        url: "/User/ImageUpload?ProductID=" + ProductID,
        dataType: 'json',
        autoUpload: true,
        maxFileSize: 3072000, // 300 MB
        done: function (e, data) {//设置文件上传完毕事件的回调函数
            if (data.result.filePath == "") {
                alert("上传失败！");
                return false;
            }
            else {
                var str1 = "<input type='hidden' value='" + data.result.PUId + "' name='InfoID' />";
                var str = "<img src='" + data.result.filePath + "' width='60' heigth='60' /><br />"
                $(".imgWarning").append(str);
                $(".PuidHide").html(str1);
            }
        }
    });
</script>
